/*
 * BIT.c
 *
 *  Created on: Jan 19, 2014
 *      Author: adijoshi
 */
//INCLUDES
#include "includes.h"
/*
 * Function: func_BIT
 *
 * Inputs:	 Mnemonic, Address_of_source, Address_of_destination
 * Outputs:  (None)
 * Condition  Codes:
 * 		Z:  set  if  result  =  0;  cleared  otherwise
 * 		N:  set  if  high-order bit of result set;  cleared  otherwise
 * 		C:  not affected.
 * 		V:  cleared.
 *
 */

void func_BIT(unsigned short address_source, unsigned short address_destination)
{
	unsigned short data_source;
	unsigned short data_destination;
	unsigned short result;

	data_source = read_from_memory(address_source,DATA);
	data_destination = read_from_memory(address_destination,DATA);

	result = (data_source & data_destination);

	update_Z_flag(result);
	update_N_flag(BIT,result);
	update_V_flag(BIT,data_source,data_destination,result);
}

